<?php

namespace app\api\Logic\Campusclass;

use app\api\model\CampusClassCourseArrangingModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;

//后台排课信息
class CampusClassCourseArrangingLogic
{
    /**
     * 获取详情
     * @param $arrangingId
     * @return array
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function getInfo($arrangingId){
        $info = CampusClassCourseArrangingModel::where('id',$arrangingId)
            ->field('id,class_id,course_id,is_set')
            ->find();
        return objToArray($info) ?? [];
    }

    /**
     * 根据班级ID获取详情
     * @param $classId
     * @return array
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function getInfoByClassId($classId){
        $info = CampusClassCourseArrangingModel::where('class_id',$classId)
            ->field('id,class_id,course_id,is_set')
            ->find();
        return objToArray($info) ?? [];
    }
}
